package contracts.assignment

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'POST'
        url value('/api/diff/assignments')
        headers {
            header('Content-Type', 'application/json;charset=UTF-8')
        }
        body("""
                 [{
                    "assignmentId":1,
                    "taskId":1,
                    "title":"title",
                    "type":"update",
                    "quizzesId":"1,2",
                    "visible":true,
                    "operatorId":1,
                    "operation":"UPDATE",
                 }] 
                """
        )
        bodyMatchers {
            jsonPath('$.[*].title', byRegex(nonEmpty()))
            jsonPath('$.[*].type', byRegex("[\\s\\S]*"))
            jsonPath('$.[*].quizzesId', byRegex("[\\s\\S]*"))
            jsonPath('$.[*].operation', byRegex("[\\s\\S]+"))
            jsonPath('$.[*].visible', byRegex(nonEmpty()))
            jsonPath('$.[*].assignmentId', byRegex(number()))
            jsonPath('$.[*].operatorId', byRegex(number()))
            jsonPath('$.[*].taskId', byRegex(number()))
        }
    }
    response {
        status 201
    }
}
